<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\SendQueuedMailable;
use Illuminate\Queue\SerializesModels;

abstract class BaseMail extends Mailable implements ShouldQueue
{
    use Queueable, SerializesModels;

    /**
     * 重写 queue 方法
     * @param null $queue
     * @param null $command
     */
    public function queue($queue = null, $command = null)
    {
        if ($queue === null) {
            dispatch($this);
        } else {
            $queue->push(new SendQueuedMailable($command), null, $this->queue);
        }
    }
}
